package com.red.star.wechat.work.site.banner;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.red.star.wechat.data.entity.BannerTemplate;
import com.red.star.wechat.data.mappers.BannerTemplateMapper;
import com.red.star.wechat.work.constant.AdminSessionHolder;
import com.red.star.wechat.work.entity.Admin;
import com.red.star.wechat.work.entity.TableContainer;
import com.red.star.wechat.work.utils.CommonUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @Description: banner模板
* @Author: liucancan
* @Date: 2018/9/26
*/
@Service
public class BannerTemlateService {

    @Resource
    private BannerTemplateMapper bannerTemplateMapper;

    /**
    * @Description: banner模板
    * @Param: [bannerTeamplate]
    * @return: TableContainer
    * @Author: liucancan
    * @Date: 2018/9/26
    */
    public TableContainer listBannerTeamlate(BannerTemplate bannerTeamplate) {
        Page<?> page = PageHelper.startPage(bannerTeamplate.getPage(), bannerTeamplate.getRows());
        Admin admin = AdminSessionHolder.get();
        bannerTeamplate.setMallCode(admin.getMallCode());
        List<BannerTemplate> testDataList = bannerTemplateMapper.findBannerTemplate(bannerTeamplate);
        return CommonUtil.backTableContainer(testDataList, page);
    }

}
